package com.eattravel.alipay;


import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */
/**
 * @author glong
 * @date 2019/9/23 16:26
 * 描述： 支付宝接口
 */
public class AlipayConfig {

//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    public final static String APP_ID = "2016101300677876";

    // 商户私钥，您的PKCS8格式RSA2私钥
    public final static String APP_PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDwHYWRax6Yj113BPxsoh/J2YR3wc9WpmMCupA4V3FpOHIIaqFe7HdZljj3Njq2TI1algaMzDAcK9BL6Ju26sI9to/YC6L4zN0hpU2uX/6qcWyIBl7fqeN0fqAfUjXBRlEQ7GwbYmm1meHmR3do0FIu5qXQABiyeNO4hLF+w65SyqPe8EyumXpiU+00wCHMqfhTADqd2F7xsB9rlXekE7pV1JN72F7fgcqkbdPvLCR6daX2zNz9D0l3eT4SxlJWLgfyk5C9EBFMT+S35LC3jv9kJTzA/a1K/fG/RxRG3DeBkPbpA/90t0utMZgWphkMpBTztoXZrkVxBTfKo0geveWBAgMBAAECggEAbK/gQterDMFwPCycmgu0uehkxtSKpp1AGf8awvYJ1uf+7gJeMxp0V6/g7z2zy8rQ/R0Fr/vJFydZ7NJIkb6n18loSRHTXi1VNyKdC/5Vxw76YoQHs9QxqgybLDJJNMhAb5mkwayFTvdtwo+85EvPt30dtw4kH70DkPU3ZrrqkHxasmfRJG3x9+20sdBSeV7CTH3ZX9DEObrx3eGAwPYmMhiRp2BnaSkgP0AMy/n+2SHHXTE7ZPIHxjboDRPP3rW1BsdDuMwvdYIz8/0u0oY7hVIESv2wsGKoavxQqwuWi2DjLp8Lea3gEt3RzKGim+nHkcKW4YVnu2FVVxnCEtVjVQKBgQD+qELNrnte9so3+jBOnHDGj21mUaej3284WUnKk/LE1v9loWEc+HBzPpayMidlV1nGm3GOdUqyYO56ZgBWjYD9HWy8W9nskj1ftJqHqfgt9Sgulv/exxGesjttaUj0Wja1mWO6P3QL65lNpqH7CqeRcvKtZUcnsqqX95s/LSRHMwKBgQDxYaHFsVy6ubMtR9fAQemLjcZVHbNxxmWiVCvpy3jBk7otz4pHdIwI8SWiwIqPbCUt/a0YDuNZTlGMEupo8fAszbXamejPfnPibXxPJagp1NcWhrEZnnKluf7fzRlUBmr7t327w+ZjEjkbq1mirQ7kCeyQRC11gDYCy2tNBLGQewKBgCWw+dI/lPsFRADtAuFfvkFlUSfnxgw3MdsBPC7DnxcLS1nbfOgwzVQBW4Scb8BMIXmH4FLZgWjNd/6dwkcNQp40ELgAUEz3iCX2MTkLKzSCKKRcrRpoFG+MqccT4jxobdiLD3utkJuDD3myxB7IAO1COjD34IQ7qYw8lbnQEKKJAoGBALRHOd5/2ATxuru/44iI8dezvIRHmYUJK1Ew0ldcC0VwguXCEsHJbukiyfwjF5mEqMQPqZ7FR9GkZ81ZN0/IGpwry32H49RM2lorcWNfeZg8iaQeVtkOeQwDvTMDaL5TyMVVRwfciQ5HRvW+ZUTVQcDZFKCu+tC+QBiYOvyb285PAoGAbwCgsAIL7308c1EifeNyblYN1vGSYCn+GeSnUKTx3Adl38DO+bsvCTrPk+/qYkWmQUFzTf1u1Liz8qh9GGefUiyopqI/+Psy6vMPAH/APUOVyOiw/FXnRrabBxVXDqRgtbJ4ZF9AwnyIvSvu3FRgJ3CV9OQxBxkU8RFctd1B1m4=";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public final static String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsRrLgen7f+P53dfWKoC18YGEEYZ8tAhvzDg/qJlO8keqGAlL6zdl4HnG0UzK2UN6OBPGLXcIGq8qxbJ+wTF5exHd2JqZXUV8t5go83GLEx157WuuQvOOj1jLC+/sq/NdGMM5FH8pGqihgZc8lrLSMYz0YmMjwdurLfnJMfhYsmbDj4IGk6tGuNRCAI6I8zT3nX4K8umhfEgRPNuPMcno2NSY9Fzqej5LI/ZFtPNGxVHCbJAr6BrZWtfjAwLc3BSJPP17puDGd49pY8Pu+oWMZgQKsZw0WkJ5QdrkzsKESaDy5/56DV1iMMX1RA1cxBHNiORId8ojnLXUnvlEp+54SQIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    //public static String notify_url = "http://localhost:8080/alipay.trade.page.pay-JAVA-UTF-8/notify_url.jsp";
    public final static String NOTIFY_URL = "http://localhost:8080/home.html";//这里根据你项目中的controller进行配置

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    //public static String return_url = "http://localhost:8080/alipay.trade.page.pay-JAVA-UTF-8/return_url.jsp";
    public final static String RETURN_URL = "http://localhost:8080/alipay/returnUrl";//这里根据你项目中的controller进行配置

    // 签名方式
    public final static String SIGN_TYPE = "RSA2";

    // 字符编码格式
    public final static String CHARSET = "utf-8";

    // 支付宝网关
    //public static String gatewayUrl = "https://openapi.alipay.com/gateway.do";//项目正式使用后使用
    public final static String GATEWAY_URL = "https://openapi.alipaydev.com/gateway.do";//使用沙箱环境时使用

    // 数据格式
    public final static String FORMAT = "JSON";

    // 支付宝网关日志信息
    public final static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}